home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Franz PD
/
Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).zip
/
Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).adf
/
tracker.library
/
Demos
/
Lock.asm
< prev
next >
Wrap
Assembly Source File
|
1994-04-15
|
7KB
|
325 lines
;TestProgramm für "tracker.library"
; Testet TRK_Lock, TRK_DupLock und TRK_Examine
NOLIST
INCLUDE "exec/LVO.i"
INCLUDE "exec/memory.i"
INCLUDE "dos/LVO.i"
INCLUDE "dos/dosextens.i"
INCLUDE "libraries/tracker.i"
LIST
HEADLEN: EQU 32 ;soviel wird ausgegeben
Print: MACRO
move.l Output,d1
move.l #\1,d2
CALLDOS VFPrintf
ENDM
_TrackerBase: EQUR a5
_DOSBase: EQUR a4
Output: EQUR d7
Buffer: EQUR a3
; WB-Message ?
sub.l a1,a1 ;a1=0->eigener Task
CALLEXEC FindTask ;Wo darf man denn nachschauen ?
move.l d0,a0
tst.l pr_CLI(a0) ;von CLI oder WB aus gestartet ?
bne fromCLI
;von WB aus:
lea pr_MsgPort(a0),a0
move.l a0,-(sp)
CALLEXEC WaitPort ;auf Start-Message warten
move.l (sp)+,a0
CALLEXEC GetMsg ;muß nachher beantwortet werden
move.l d0,WBenchMsg
fromCLI:
; Tracker-Library öffnen
OPENLIB TrName
tst.l d0
beq ende_all
move.l d0,_TrackerBase
TRK_OPENSTDLIB DOS,36
tst.l d0
beq ende_trk
move.l d0,_DOSBase
tst.l WBenchMsg
bne fromWB
;von CLI aus -> Ausgaben ins CLI-Fenster
CALLDOS Output
move.l d0,Output
bra main
;von WB aus gestartet -> eigenes Window nötig
fromWB: move.l #WdName,d1
move.l #MODE_OLDFILE,d2
CALLTRK TRK_Open
move.l d0,Output
;---------------------------------------------------------------------------
;Dateipuffer anlegen
main: move.l #HEADLEN,d0
move.l #MEMF_ANY,d1
CALLTRK TRK_AllocMem
tst.l d0
beq ende_main
move.l d0,Buffer
;Haupt-Testteil
LOCK: MACRO ;Name
move.l #\1,d1
bsr Lock
ENDM
UNLOCK: MACRO ;Lock
move.l \1,d1
bsr UnLock
ENDM
EXAMINE: MACRO ;Lock
move.l \1,d1
bsr Examine
ENDM
FREE: MACRO ;FIB
move.l \1,d1
bsr FreeFIB
ENDM
SHORTINFO: MACRO ;FIB
move.l \1,a0
bsr ShortInfo
ENDM
CMPFIB: MACRO ;FIB1, FIB2
move.l \1,a0
move.l \2,a1
bsr CmpFIB
ENDM
;Test 1: Lock zu 's:Startup-Sequence' holen, dazu FIB holen und daraus
; Länge und Dateinamen lesen.
LOCK Name_1
move.l d0,d1
beq 3$
move.l d0,-(sp)
bsr DupLock
EXAMINE (sp)+
SHORTINFO d0
;Test 2: Lock zu 'l:' holen, dazu FIB holen und Dateinamen (und hoffentlich
; nicht -Länge) auslesen. Der Lock-BPTR wird vergessen.
3$: LOCK Name_2
move.l d0,-(sp)
EXAMINE d0
move.l d0,FIB_2
SHORTINFO d0
move.l (sp)+,d1
beq 1$
bsr DupLock
move.l d0,DLock_2
EXAMINE d0
CMPFIB FIB_2,d0
;Test 3: Lock zu 's:MakeShell' holen, dazu FIB holen und daraus Länge und
; Dateinamen lesen.
1$: LOCK Name_3
move.l d0,Lock_3
EXAMINE d0
move.l d0,FIB_3
SHORTINFO d0
;FIB_2 freigeben
FREE FIB_2
;Test 4: Lock zu 'devs:MountList' holen, dazu FIB holen und daraus Länge und
; Dateinamen lesen.
LOCK Name_4
move.l d0,Lock_4
EXAMINE d0
move.l d0,FIB_4
SHORTINFO d0
move.l Lock_4,d1
beq 2$
bsr DupLock
move.l d0,DLock_4
EXAMINE d0
CMPFIB FIB_4,d0
;Lock_3, DLock_2 und FIB_3 freigeben
2$: FREE FIB_3
UNLOCK DLock_2
UNLOCK Lock_3
;Test 5: Lock zu 'sys:' holen
LOCK Name_5
move.l d0,d1
beq 4$
bsr DupLock
;Lock_4, DLock_4 freigeben
4$: UNLOCK Lock_4
UNLOCK DLock_4
;---------------------------------------------------------------------------
ende_main:
;ggf. End-Botschaft und Verzögerung
tst.l WBenchMsg
beq ende_trk
move.l Output,d1
move.l #GoodBye,d2
moveq #GoodByeLen,d3
CALLDOS Write
move.l #150,d1
CALL Delay
;Library schließen
ende_trk:
CLOSELIB _TrackerBase
ende_all:
tst.l WBenchMsg ;war da was ?
beq toCLI ;na dann halt nicht
;Message zur WB zurück
move.l WBenchMsg,a1
CALLEXEC ReplyMsg
toCLI: moveq #0,d0
rts
;---------------------------------------------------------------------------
; Unterprogramm: File des Namens d1 locken
; Parameter: d1 = Namens-Zeiger
; Ergebnis: Lock-BPTR
Lock: movem.l d1/d2,-(sp)
move.l #ACCESS_READ,d2
CALLTRK TRK_Lock
move.l d0,4(sp)
move.l sp,d3
Print Lock_Text
add.w #4,sp
move.l (sp)+,d0
rts
;---------------------------------------------------------------------------
; Unterprogramm: weiteres Lock erstellen
; Parameter: d1 = Original-Lock-BPTR
; Ergebnis: Kopie-Lock-BPTR
DupLock:
movem.l d1/d2,-(sp)
CALLTRK TRK_DupLock
move.l d0,4(sp)
move.l sp,d3
Print DupLock_Text
add.w #4,sp
move.l (sp)+,d0
rts
;---------------------------------------------------------------------------
; Unterprogramm: zwei FIBs vergleichen
; Parameter: a0/a1 - die FIB-Adressen
; Ergebnis: -
CmpFIB: movem.l a0-a2,-(sp) ;a2 = Platzhalter für Ergebnis-String
move.w #fib_SIZEOF-1,d0
1$: cmp.b (a0)+,(a1)+
bne 2$
dbra d0,1$
;gleich
move.l #FIBS_equal,8(sp)
bra 3$
;ungleich
2$: move.l #FIBS_nonequal,8(sp)
3$: move.l sp,d3
Print FIB_Text
add.w #12,sp
rts
;---------------------------------------------------------------------------
; Unterprogramm: Lock d1 untersuchen
; Parameter: d1 = Lock-BPTR
; Ergebnis: FIB-Zeiger
Examine:
movem.l d1/d2,-(sp)
CALLTRK TRK_Examine
move.l d0,4(sp)
move.l sp,d3
Print Examine_Text
add.w #4,sp
move.l (sp)+,d0
rts
;---------------------------------------------------------------------------
; Unterprogramm: Kurzinfo aus FIB generieren
; Parameter: a0 = FIB-Zeiger
; Ergebnis: -
ShortInfo:
tst.l fib_DirEntryType(a0)
bmi 1$
;Directory:
pea fib_FileName(a0)
move.l sp,d3
Print SI_Dir_Text
add.w #4,sp
rts
;File:
1$: move.l fib_Size(a0),-(sp)
pea fib_FileName(a0)
move.l sp,d3
Print SI_File_Text
add.w #8,sp
rts
;---------------------------------------------------------------------------
; Unterprogramm: FIB freigeben
; Parameter: d1 = Zeiger auf den FIB
; Ergebnis: -
FreeFIB: tst.l d1
bne 1$
rts
1$: move.l d1,-(sp)
CALLTRK TRK_FreeFIB
move.l sp,d3
Print Free_Text
add.w #4,sp
rts
;---------------------------------------------------------------------------
; Unterprogramm: Lock freigeben
; Parameter: d1 = BPTR auf das Lock
; Ergebnis: -
UnLock: tst.l d1
bne 1$
rts
1$: move.l d1,-(sp)
CALLTRK TRK_UnLock
move.l sp,d3
Print UnLock_Text
add.w #4,sp
rts
;---------------------------------------------------------------------------
WBenchMsg: dc.l 0
DLock_2: dc.l 0
FIB_2: dc.l 0
Lock_3: dc.l 0
FIB_3: dc.l 0
Lock_4: dc.l 0
DLock_4: dc.l 0
FIB_4: dc.l 0
TrName: TRACKERNAME
WdName: dc.b "CON:0/0/640/200/Dos-Test für tracker.library",0
GoodBye: dc.b 10,"Bye - closing soon !"
GoodByeLen: equ *-GoodBye
Name_1: dc.b "s:Startup-Sequence",0
Name_2: dc.b "l:",0
Name_3: dc.b "s:MakeShell",0
Name_4: dc.b "devs:MountList",0
Name_5: dc.b "sys:",0
CrLf: dc.b 10,0
ReadNN: dc.b "%ld Bytes of File with FileHandle at 4*$%06lx read : ",10,0
Lock_Text: dc.b "Lock(",34,"%s",34,") returns $%06lx",10,0
DupLock_Text: dc.b "DupLock($%06lx) returns $%06lx",10,0
UnLock_Text: dc.b "Lock at 4*$%06lx freed",10,0
Examine_Text: dc.b "Examine($%06lx) returns FIB at $%06lx",10,0
Free_Text: dc.b "FIB at $%06lx freed",10,0
SI_Dir_Text: dc.b "The examined item was the directory %s",10,0
SI_File_Text: dc.b "The examined item was the file %s. It contains %ld Bytes",10,0
FIBS_equal: dc.b "are euqal",0
FIBS_nonequal: dc.b "differ",0
FIB_Text: dc.b "The FIBs at $%06lx and $%06lx %s",10,0
END